/**
 * 搜索并刷新表格数据
 */
function doSearch(){
	var param_str=getSearchParam();
  	$('#tt').datagrid('load',param_str);
}

/**
 * 搜索的参数
 * 前缀  	mk_eq.user_name  等于
 * 		mk_gt.user_name	大于
 * 		mk_gte.user_name	大于等于
 * 		mk_lt.user_name	小于
 * 		mk_lte.user_name	小于等于
 * 		mk_like.user_name	like
 * 		
 * @returns
 */
function getSearchParam(){
	var param = {};
	var id =$("input[name='mk_eq.id']").val();
	var user_name=$("input[name='mk_like.user_name']").val();
	var mobile =$("input[name='mk_like.mobile']").val();
	var start_create_time=$("input[name='mk_gte.create_time']").val();
	var end_create_time=$("input[name='mk_lte.create_time']").val();
	var group_id = $("input[name='mk_eq.group_id']").val();
	
	if(""!=id){
		param['mk_eq.id']=id;
	}
	
	if(""!=user_name){
		param['mk_like.user_name']=user_name;
	}
	
	if(""!=mobile){
		param['mk_like.mobile']=mobile;
	}
	
	if("0"!=group_id){
		param['mk_eq.group_id']=group_id;
	}
	
	if(""!=start_create_time){
		var start_date = new Date(start_create_time);
		param['mk_gte.create_time']=start_date.getTime()/1000;
	}
	
	if(""!=end_create_time){
		var end_date = new Date(end_create_time);
		param['mk_lte.create_time']=end_date.getTime()/1000;
	}
	
	//return JSON.stringify(param);
	return param;
}

/**
 * 
 * @param value	当前字段值
 * @param row	当前的行对象,可以通过row.id 取值
 * @param index	第几行
 * @returns {String}
 */
function formatOperation(value, row, index){
	var s =createWindowOperation("编辑","editAjax",row.id,600,400)
		+createOperation("删除","del",row.id)
		+createOperation("账户明细","userMoneyLog",row.id)
		+createOperation("佣金明细","fxUserMoneyLog",row.id)
		+createOperation("积分明细","userScoreLog",row.id)
		+"</br>"
		+createOperation("账户操作","account",row.id)
		+createOperation("提现记录","userWithdraw",row.id)
		+createOperation("充值记录","paymentNotice",row.id)
		;
	
	return s;
}



/**
 * 账户明细
 * @param id
 */
function userMoneyLog(id){
	var url = app_url+"/userMoneyLog/index.do?mk_eq.user_id="+id;
	jump_request(url);
}

/**
 * 佣金明细
 * @param id
 */
function fxUserMoneyLog(id){
	var url = app_url+"/fxUserMoneyLog/index.do?mk_eq.user_id="+id;
	jump_request(url);
}

/**
 * 积分明细
 * @param id
 */
function userScoreLog(id){
	var url = app_url+"/userScoreLog/index.do?mk_eq.user_id="+id;
	jump_request(url);
}

/**
 * 充值记录
 * @param id
 */
function paymentNotice(id){
	var url = app_url+"/paymentNotice/index.do?mk_eq.user_id="+id;
	jump_request(url);
}

/**
 * 提现记录
 * @param id
 */
function userWithdraw(id){
	var url = app_url+"/userWithdraw/index.do?mk_eq.user_id="+id;
	jump_request(url);
}

/**
 * 账户操作
 * @param id
 */
function account(id){
	var url = module_url+"/account.do?id="+id;
	$('#win').window({    
	    width:600,    
	    height:400,
	    title:'账户操作',
	    collapsible:false,
	    minimizable:false,
	    maximizable:false,
	    modal:true   
	});  
	$('#win').window('refresh', url);  
}

/**
 * 弹窗编辑用户
 * @param id
 */
function editUser(id){
	var url = module_url+"/edit.do?id="+id;
	$('#win').window({    
	    width:600,    
	    height:400, 
	    title:'用户编辑',
	    collapsible:false,
	    minimizable:false,
	    maximizable:false,
	    modal:true   
	});  
	$('#win').window('refresh', url);  
}

/**
 * 添加
 * @param id
 */
function addUser(){
	var url = module_url+"/add.do";
	$('#win').window({    
	    width:600,    
	    height:400, 
	    title:'添加编辑',
	    collapsible:false,
	    minimizable:false,
	    maximizable:false,
	    modal:true   
	});  
	$('#win').window('refresh', url);  
}




